﻿#include <CommonUnits/Units/Current.h>
#include <gtest/gtest.h>

TEST(CurrentTest, CastTest)
{
    EXPECT_EQ(CU::Ampere(1), CU::Milliampere(1e3));
    EXPECT_EQ(CU::Milliampere(1), CU::Microampere(1E3));
    EXPECT_EQ(CU::Microampere(1), CU::Nanoampere(1e3));
    EXPECT_EQ(CU::Nanoampere(1), CU::Picoampere(1e3));
    EXPECT_EQ(CU::Picoampere(1), CU::Femtoampere(1e3));
    EXPECT_EQ(CU::Femtoampere(1), CU::Attoampere(1e3));
    EXPECT_EQ(CU::Kiloampere(1), CU::Ampere(1e3));
    EXPECT_EQ(CU::Megaampere(1), CU::Kiloampere(1e3));
    EXPECT_EQ(CU::Gigaampere(1), CU::Megaampere(1e3));
    EXPECT_EQ(CU::Teraampere(1), CU::Gigaampere(1e3));
    EXPECT_EQ(CU::Petaampere(1), CU::Teraampere(1e3));
    EXPECT_EQ(CU::Exaampere(1), CU::Petaampere(1e3));
}

TEST(CurrentTest, Literals)
{
    using namespace CU::Current::Literals;
    EXPECT_EQ(1.0_A, 1e3_mA);
    EXPECT_EQ(1.0_mA, 1e3_uA);
    EXPECT_EQ(1.0_uA, 1e3_nA);
    EXPECT_EQ(1.0_nA, 1e3_pA);
    EXPECT_EQ(1.0_pA, 1e3_fA);
    EXPECT_EQ(1.0_fA, 1e3_aA);
    EXPECT_EQ(1.0_kA, 1e3_A);
    EXPECT_EQ(1.0_MA, 1e3_kA);
    EXPECT_EQ(1.0_GA, 1e3_MA);
    EXPECT_EQ(1.0_TA, 1e3_GA);
    EXPECT_EQ(1.0_PA, 1e3_TA);
    EXPECT_EQ(1.0_EA, 1e3_PA);
}

TEST(CurrentTest, ToUnit)
{
    using namespace CU::Current::Literals;
    EXPECT_EQ(1e3_A, CU::Current::toUnit<CU::Ampere>(1, CU::Kiloampere::unit()));
    EXPECT_EQ(1e3_kA, CU::Current::toUnit<CU::Kiloampere>(1, CU::Megaampere::unit()));
    EXPECT_EQ(1e3_MA, CU::Current::toUnit<CU::Megaampere>(1, CU::Gigaampere::unit()));
    EXPECT_EQ(1e3_GA, CU::Current::toUnit<CU::Gigaampere>(1, CU::Teraampere::unit()));
    EXPECT_EQ(1e3_TA, CU::Current::toUnit<CU::Teraampere>(1, CU::Petaampere::unit()));
    EXPECT_EQ(1e3_PA, CU::Current::toUnit<CU::Petaampere>(1, CU::Exaampere::unit()));
    EXPECT_EQ(1e3_mA, CU::Current::toUnit<CU::Milliampere>(1, CU::Ampere::unit()));
    EXPECT_EQ(1e3_uA, CU::Current::toUnit<CU::Microampere>(1, CU::Milliampere::unit()));
    EXPECT_EQ(1e3_nA, CU::Current::toUnit<CU::Nanoampere>(1, CU::Microampere::unit()));
    EXPECT_EQ(1e3_pA, CU::Current::toUnit<CU::Picoampere>(1, CU::Nanoampere::unit()));
    EXPECT_EQ(1e3_fA, CU::Current::toUnit<CU::Femtoampere>(1, CU::Picoampere::unit()));
    EXPECT_EQ(1e3_aA, CU::Current::toUnit<CU::Attoampere>(1, CU::Femtoampere::unit()));
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}